package packageCommand;

import packagerole.Merchant;
import packagerole.User;

public abstract class CommandFactory {

    public static enum CommandCode {
        // system
        EXIT,
        HELP,
        USERLOGIN,
        USERSIGNUP,
        MERCHANTSIGNUP,
        MERCHANTLOGIN,
        LISTUSER,
        LISTMERCHANT,
        
        // USER
        LIST,
        CREATE,
        CHECK,
        CANCEL,
        PAY,
        RECEIVE,
        RECHARGE,
        
        //MERCHANT
        ALTERORDER,
        ALTERGOODS,
        SEND
        
    }

    public static CommandFactory getFactory(User user) {
    	
        if (user == null) {
            return new SystemCommandFactory();
        }else if(user instanceof Merchant){
        	Merchant merchant = (Merchant)user;
        	return new MerchantCommandFactory(merchant);
        	}
        return new UserCommandFactory(user);
    }

    public abstract Command buildCommand(CommandCode cmd);

}
